<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css" />

    <title>账号对接失败</title>
    <style>
        .ErrorTab{
            width: 80%;
            margin: 0 auto;
            
        }
        .ErrorTab tr{
            font-size: 14px !important;
        }
        .ErrorTab tr th{
            font-size: 14px !important;
            line-height: 20px;
            background: #ccc;
            font-weight: bold;
            padding: 10px;
        }
        .ErrorTab tr td{
            font-size: 14px !important;
            line-height: 20px;
            padding: 10px;
        }
        .MoreBig{
            background: #fff;
            padding: 30px;
            padding-bottom: 50px;
        }
        .MoreBig_but{
            display: flex;
            justify-content: flex-end;
        }
        .ErrorButton{
            padding: 5px 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-left: 20px;
            cursor: pointer;
        }
        .ErrorButton:hover{
            color: #4A90E2;
}
    </style>
</head>
<body data-id="35">
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页  
    <span class="c-gray en">&gt;</span>会员管理
    <span class="c-gray en">&gt;</span>客户组管理
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
<article class="page-container">
    <div class="MoreBig">
        <div class="MoreBig_but">
            <input type="button" class="ErrorButton" onclick="allGenrate()" value="全部重新生成"/>
        </div>
        <table class="table table-border table-bg table-hover table-sort mt-10" id="tables">
            <thead>
            <tr class="text-c">
                <th width="50">客户组编码</th>
                <th width="100">客户组名称</th>
                <th width="100">模块</th>
                <th width="100">客户平台账号</th>
                <th width="100">原因</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody class="shun">
            </tbody>
        </table>
        <div class="dataTables_wrapper goods_fanye clearfix mt-5">
            <div class="f-r pageturning M-box3"></div>
        </div>
    </div>
    
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script>
<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../lib/jquery.jedate.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../ht-js/Project.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<!--引入分页-->
<link rel="stylesheet" href="../../../lib/pagination/pagination.css">
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<!--权限控制-->
<script type="text/javascript" src="../../../ht-js/power.js?rev=@@hash"></script>

<script>

    function Genrate(id){
        let idList = {
            idList: [id]
        }
        $.ajax({
            url: root.orderInter.ErrorGrene,
            // url: 'https://t.fsyuncai.com/api/admin/amembership/customerUser/retrySync',
            cache: false,  //禁用缓存
            type: "POST",
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(idList),
            success: function (data) {
                if (data.code == 0) {
                    $.Huimodalalert('重新生成成功！', 2000);
                    getErrorAjax()              //操作成功后重新获取列表数据
                    } else {
                        showMsg(5, data.msg);
                    }
                },
                error: function () {
                    $.Huimodalalert('失败！', 2000);
                }
        });
    }

    function allGenrate(){
        $.ajax({
            url: root.orderInter.ErrorGreneAll,
            // url: 'https://t.fsyuncai.com/api/admin/amembership/customerUser/retrySyncAll',
            cache: false,  //禁用缓存
            type: "POST",
            dataType: 'json',
            contentType: "application/json",
            data: {},
            success: function (data) {
                if (data.code == 0) {
                    $.Huimodalalert('重新生成成功！', 2000);
                    getErrorAjax()              //操作成功后重新获取列表数据
                } else {
                    showMsg(5, data.msg);
                }
            },
            error: function () {
                $.Huimodalalert('失败！', 2000);
            }
        });
    }
    getErrorAjax()
    function getErrorAjax(){
        let params = {
            pageNum: 1,
            pageSize: 30
        }
        $.ajax({
            url: root.orderInter.ErrorSignList,
            // url: 'https://t.fsyuncai.com/api/admin/amembership/customerUser/syncFailList',
            cache: false,  //禁用缓存
            type: "POST",
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(params),
            success: function (data) {
                initDataTable(data.data.data)
                $('.M-box3').pagination({
                        pageCount: data.data.pageCount,
                        jump: true,
                        coping: true,
                        prevContent: '上页',
                        nextContent: '下页',
                        callback: function (api) {
                            $.ajax({
                                url: root.orderInter.ErrorSignList,
                                // url: 'https://t.fsyuncai.com/api/admin/amembership/customerUser/syncFailList',
                                cache: false,  //禁用缓存
                                type: "POST",
                                dataType:'json',
                                contentType: "application/json",
                                data: JSON.stringify({
                                    "pageNum":api.getCurrent(),
                                    "pageSize":20
                                }),
                                success: function (result) {
                                    initDataTable(result.data.data)
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert(XMLHttpRequest);
                                }
                        });
                    }
                });
            },
            error: function () {
                $.Huimodalalert('失败！', 2000);
            }
        });
    }


    function initDataTable(dataSource) {
        var dttable = $('#tables').dataTable(); // 初始化dataTable，清空上一个值
        dttable.fnClearTable(); //清空一下table
        dttable.fnDestroy(); //还原初始化了的datatable
        $("#tables").DataTable({
            // "order": false,
            "autoWidth": false,
            "ordering": false,
            "searching": false,
            "paging": false,
            "retrieve": true,
            "destroy": true,
            "bAutoWidth": true,
            "bLengthChange": true,
            "aLengthMenu": false,
            "oLanguage": {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "前一页",
                    "sNext": "后一页",
                    "sLast": "尾页"
                },
                "sZeroRecords": "没有检索到数据",
            },
            data: dataSource,
            columns: [
                { "data": "mainCustomerCode" ,"orderable":false},
                { "data": "mainCustomerName" },
                { "data": "module" },
                { "data": "loginAccount" },
                { "data": "failReason" },
                // { "data": "mainCustomerId" }
                {
                    "render": function (data, type, row, meta) {
                        return `<a onclick="Genrate(${row.id})">重新生成</a>`
                    },
                }
            ]
        });

    };

        //弹框
    function showMsg(icon, msg) {
        layer.msg(msg, {
            icon: icon,
            time: 1000
        });
    }
</script>

</body>
</html>